import datetime
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime
from sqlalchemy.orm import relationship

from app.db.base import Base

class Gallery(Base):
    __tablename__ = "gallery"

    id = Column(Integer, primary_key=True, index=True)
    image_url = Column(String, nullable=False)
    prompt = Column(String, nullable=False)
    category = Column(String, index=True, nullable=False) # e.g., "风景", "人物", "抽象"
    uploaded_by = Column(Integer, ForeignKey("users.id"), nullable=False)
    created_at = Column(DateTime, default=datetime.datetime.now(datetime.timezone.utc))

    # Relationship to the admin user who uploaded it
    uploader = relationship("User") # Add back_populates="gallery_uploads" in User model
